#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author : hai.long
import os
import threading
from utils.common import get_local_ip
from _server.connector import start_send_record_steps_server, start_ctrl_server


def main():
    print("smart-playwright-gird version 1.0.1")
    server_ip, screen_port, control_port = get_local_ip(), 8765, 8766
    print(server_ip, screen_port, control_port)
    t1 = threading.Thread(target=start_send_record_steps_server, name="screen", args=(server_ip, screen_port,))
    t1.start()
    try:
        start_ctrl_server(server_ip, control_port)
    except KeyboardInterrupt:
        os._exit(0)  # ctrl+c 主动关闭程序，程序直接退出


if __name__ == '__main__':
    main()
    # pip3 install psutil -i https://pypi.tuna.tsinghua.edu.cn/simple/
    # 打包命令 Pyinstaller -F -w --hidden-import urllib3 smart-playwright-grid.py
    # 国内镜像： https://pypi.tuna.tsinghua.edu.cn/simple/
    # pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
    # npx playwright codegen --viewport-size "1920,1080" --target python -o ./gen_script.py -b chromium http://admintest.snkoudai.com/login
    # playwright codegen --viewport-size "1920,1080" --target python -o ./gen_script.py -b chromium https://test.snkoudai.com/index.html#/agriproductstorage/list/company=13304&farm=15414
